<template>
  <div class="person">
    {{ num }}
    <br>
    <button @click="addNum()">点我加1</button>
  </div>
</template>

<script lang="ts" setup name="Person">
import { ref, onMounted, onBeforeUpdate, onUpdated, onBeforeMount, onBeforeUnmount, onUnmounted } from 'vue'

let num = ref(1);

function addNum() {
  num.value += 1
}

console.log('创建')

onBeforeMount(()=>console.log('挂载前'));

onMounted(()=>console.log('挂载后'));

onBeforeUpdate(()=>console.log('更新前'));

onUpdated(()=>console.log('更新后'));

onBeforeUnmount(()=>console.log('卸载前'));

onUnmounted(()=>console.log('卸载后'));

</script>
<style scoped>
.person {
  background-color: skyblue;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}

button {
  margin: 0 5px;
}
</style>